using namespace std;


class Solution {
public:
    int minFlips(int a, int b, int c) {
        int res = 0;
        for (int i=0; i<32; ++i) {  // 32 bits for integers
            int bitA = (a >> i) & 1;
            int bitB = (b >> i) & 1;
            int bitC = (c >> i) & 1;
            if (bitC == 0 && (bitA ^ bitB)) {
                res++;
            } else if (bitC == 0 && (bitA & bitB)) {
                res += 2;
            } else if (bitC == 1 && !(bitA | bitB)) {
                res++;
            }
        }
        return res;
    }
};
